#include <stdio.h>

int main()
{
    int nCase;
    for (scanf("%d", &nCase); nCase > 0; nCase--)
    {
        int score;
        scanf("%d", &score);
        if (score < 0 || score > 100)
            printf("X");
        else if (score < 60)
            printf("E");
        else if (score < 70)
            printf("D");
        else if (score < 80)
            printf("C");
        else if (score < 90)
            printf("B");
        else
            printf("A");
        printf("\n");
    }
    return 0;
}
